package com.gbx.sportsnews.fragments;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.gbx.sportsnews.R;
import com.gbx.sportsnews.adapter.NewsPagerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class NewsFragment extends Fragment {
    private String[] tabTitles=new String[]{"推荐","NBA","中国足球","国际足球","中国篮球",
            "综合","视频","最“董”球","电竞","图说","网球","羽毛球","高尔夫","深度","竞猜","铿锵玫瑰"};
    private List<Fragment> list;
    private ViewPager pager;
    private NewsPagerAdapter adapter;

    public NewsFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_news, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        list=new ArrayList<>();
        list.add(new RecommendFragment());
        list.add(new NBAFragment());
        list.add(new ChinaFootballFragment());
        list.add(new InternationalFootballFragment());
        list.add(new ChinaBasketballFragment());
        list.add(new SynthesizeFragment());
        list.add(new VideoFragment());
        list.add(new KnowBallBestFragment());
        list.add(new ECFragment());
        list.add(new PictureFragment());
        list.add(new TennisFragment());
        list.add(new BadmintonFragment());
        list.add(new GolfFragment());
        list.add(new DeepthFragment());
        list.add(new GuessingFragment());
        list.add(new RosesFragment());
        TabLayout tabLayout = (TabLayout) view.findViewById(R.id.news_tab);
        pager = (ViewPager) view.findViewById(R.id.news_pager);
        adapter = new NewsPagerAdapter(getFragmentManager(), getContext(), tabTitles, list);
        pager.setAdapter(adapter);
        tabLayout.setupWithViewPager(pager);
    }
}
